package itypes

import (
	"github.com/hwcer/logger"
	"github.com/hwcer/updater"
	"server/game/model"
	"server/share/config"
)

var Record = NewIType(config.ITypeRecord)

func init() {
	if err := updater.Register(updater.ParserTypeCollection, updater.RAMTypeAlways, &model.Record{}, Record); err != nil {
		logger.Panic(err)
	}
	Record.SetCreator(recordCreator)
}

func recordCreator(u *updater.Updater, iid int32, val int64) (r any, err error) {
	v := &model.Record{
		Uid:   u.Uid(),
		IID:   iid,
		Value: val,
	}
	v.OID = Record.ObjectId(u, iid)
	return v, nil
}
